<?php

namespace app\company\controller;

use app\common\controller\CompanyController;
use app\common\service\annotation\ControllerAnnotation;
use app\common\service\annotation\NodeAnnotation;
use app\company\model\CompanyPrintLog;
use app\Request;
use think\App;

/**
 * @ControllerAnnotation(title="打印日志")
 */
class PrintLog extends CompanyController
{
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->model = new CompanyPrintLog();
    }

    /**
     * @NodeAnnotation(title="打印日志")
     */
    public function add(Request $request)
    {
        $this->checkPost();
        $post = $request->post();
//        $rule = [
//                'print_id|打印单id' => 'require',
//                'print_type|打印类型' => 'require',
//        ];
//        $this->validate($post, $rule);
        $post['company_id'] = $this->companyId;
        // 打印人
        $post['user_id'] = $this->uid;
//        $row = $this->model->where('print_id',$post['print_id'])->where('print_type',$post['print_type'])->where('user_id',$post['user_id'])->find();
        try {
//            if($row){
//                $row->save($post);
//            }else{
//            }
            $this->model->save($post);
        }catch (\Exception $e){
            return $this->error($e->getMessage());
        }
        return $this->success('操作成功');
    }
}